dir=$(cd "$(dirname "$0")"; pwd)
hexo_dir="$dir/export/mynote"

set_home_page() {
	config_file=$hexo_dir/_config.yml
	home_page=$1
	if test -z $home_page; then
		exit
	fi
    ln_no=`grep -n home_page $config_file | cut -d ':' -f 1`
	if test -z "$ln_no"; then
		ln_no=`grep -n timezone $config_file | cut -d ':' -f 1`
		if test -z "$ln_no"; then
			ln_no=0
		fi
		sed -i "${ln_no}a home_page: $home_page" $config_file
	else
		sed -i "${ln_no}c home_page: $home_page" $config_file
	fi
}
if test -z "$1"; then
	echo "Usage set_home_page <hexo_url>"
else
	set_home_page $1
fi
